SetBackground("titlemenu")
AddMousePointer("cursor", 32, 32)
AnimateMousePointer("pointer")
--AddText("testo1", "AdvEng Engine", uisettings.defaultFont, 21, Color(255,255,255,255), 100, 100, 250, 50)
vals = StringArray(4)
vals[0] = "Nuova Partita"
vals[1] = "Test Battaglia"
vals[2] = "Test Video"
vals[3] = "Esci"
AddMenu("menu1", "titleMenu.menu1", uisettings.defaultFont, 21, Color(255,255,255,255), Color(100,100,100,255), 100, 500, 250, 50, 10, vals)
GetMenu("menu1").active = false
AddRect("rect1", 70, 470, 300, 280)
FadeIn(1000)
AddTimeTrigger(GetCurrentTime() + 1100, "titleMenu.afterFadePRE")
soundEngine.PlayMusic("menu", false, 0)

titleMenu.menu1 = function ()
	sel = GetMenu("menu1").selectedIndex
	if sel == 0 then
		FadeOut(500)
		soundEngine.StopMusic(true, 500)
		AddTimeTrigger(GetCurrentTime() + 500, "titleMenu.afterFade1")
	elseif sel == 1 then
		FadeOut(500)
		soundEngine.StopMusic(true, 500)
		AddTimeTrigger(GetCurrentTime() + 1500, "titleMenu.afterFade2")
	elseif sel == 2 then
		FadeOut(500)
		soundEngine.StopMusic(true, 500)
		AddTimeTrigger(GetCurrentTime() + 500, "titleMenu.afterFade3")
	elseif sel == 3 then
		FadeOut(500)
		soundEngine.StopMusic(true, 500)
		AddTimeTrigger(GetCurrentTime() + 500, "titleMenu.afterFade4")
	end
end

titleMenu.afterFadePRE = function()
	GetMenu("menu1").active = true
end

titleMenu.afterFade1 = function()
	StopAllSound()
	LoadField("entrata")
end

titleMenu.afterFade2 = function()
	StopAllSound()
	LoadField("battle")
end

titleMenu.afterFade3 = function()
	--LoadField("credits")
	PlayVideo("video.mp4", "titleMenu.afterVideo")
end

titleMenu.afterVideo = function()
	LoadField("titleMenu")
end

titleMenu.afterFade4 = function()
	EndGame()
end